<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // 定义一个含有30个整型元素的数组，按顺序分别赋予从2开始的偶数；然后按顺序每五个数求出一个平均值，放在另一个数组中并输出。试编程。
        var arr = [];

        for (i = 2; i <= 60; i++) {
            if (i % 2 == 0) {
                arr.push(i)
                
            }
            
        }
        // console.log(arr)


        var total = 0;
        var newarr = [];
        for(var j=0;j<arr.length;j++){
            total += arr[j];
            // console.log(total);
            if((j+1)%5==0){
                // console.log(total);  
                var num = total/5;
                // console.log(num);
                newarr.push(num);
                total = 0;
            }
        }
        console.log(newarr);

    </script>
</body>

</html>